package com.yonyou.cyxdms.sysAuth.service.mapper;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yonyou.cyx.framework.dao.base.SuperMapper;
import com.yonyou.cyxdms.sysAuth.service.dto.OrgDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.dealerchannel.DealerDetailDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.dealerchannel.DealerInfoDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.dealerchannel.DealerListDTO;
import com.yonyou.cyxdms.sysAuth.service.entity.DealerInfoPO;
import com.yonyou.cyxdms.sysAuth.service.vo.companyorg.DealerOrgAreaVO;
import com.yonyou.cyxdms.sysAuth.service.vo.companyorg.DealerPageVO;
import com.yonyou.cyxdms.sysAuth.service.vo.dealerchannel.DealerOrgVO;
import com.yonyou.cyxdms.sysAuth.service.vo.dealerchannel.SaleInfoVO;
import com.yonyou.cyxdms.sysAuth.service.vo.user.DealerUserVO;
import com.yonyou.cyxdms.sysmanage.client.vo.dealer.DealerInfoAVO;
import com.yonyou.cyxdms.sysmanage.client.vo.dealer.DealerInfoParentVO;
import com.yonyou.cyxdms.sysmanage.client.vo.dealer.DealerOrAscOrCompanyVO;
import com.yonyou.cyxdms.sysmanage.client.vo.dealer.DealerPictureVO;
import com.yonyou.cyxdms.sysmanage.client.vo.org.OrgParentVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 经销商基本信息 Mapper 接口
 * </p>
 *
 * @author maxingjian
 * @since 2019-08-26
 */
public interface DealerInfoMapper extends SuperMapper<DealerInfoPO> {

    public List<DealerInfoDTO> dealerInfoList(Page var1, @Param("dealer") DealerListDTO dealer);

    DealerInfoDTO dealerDetailInfo(@Param("detail") DealerDetailDTO detail);

    /**
     * 根据经销商ID查询在售品牌列表
     *
     * @author dengqiang
     * @since 2018/12/13
     */
    public List<Long> getSaleCarbrandIdList(@Param("dealerId") Long dealerId, @Param("appId") String appId);

    /**
     * 根据经销商id获取经销商试驾地址
     *
     * @author dengqiang
     * @since 2019/2/14
     */
    public String getDriveAddress(@Param("dealerId") Long dealerId);

    /**
     * 经销商名称(根据appId和dearCode可以确定唯一性)
     *
     * @author dengqiang
     * @since 2019/5/16
     */
    DealerInfoPO getDealerCode(@Param("appId") String appId, @Param("dealerCode") String dealerCode);


    /**
     * 获取维修站简称
     *
     * @param
     * @return java.util.List<java.util.Map < java.lang.String, java.lang.Object>>
     * @author dengqiang
     * @since 2019/8/19
     */
    List<Map<String, Object>> queryDealerShortname();

    List<DealerOrAscOrCompanyVO> getDealerByCode(@Param("ownerCode") String ownerCode);

    List<DealerOrAscOrCompanyVO> getAscByCode(@Param("code") String code);

    List<DealerOrAscOrCompanyVO> getCompanyByCode(@Param("code") String code);

    Integer save(DealerInfoPO dealerInfoPO);

    /**
     * 批量查询dealer信息
     *
     * @param appId
     * @param isBlack
     * @param ownerCodes
     * @return:
     * @auther: tanjie
     * @since: 2019/9/23
     */
    List<Map<String, String>> getDealerInfoByCodes(@Param("ownerCodes") List<String> ownerCodes,
                                                   @Param("isBlack") Boolean isBlack,
                                                   @Param("appId") String appId,
                                                   @Param("ownerCode") String ownerCode,
                                                   @Param("start") Integer start,
                                                   @Param("pageSize") Integer pageSize,
                                                   @Param("orgId") String orgId);

    List<Map<String, String>> getTotalDealerInfoByCodes(@Param("ownerCodes") List<String> ownerCodes,
                                                        @Param("isBlack") Boolean isBlack,
                                                        @Param("appId") String appId,
                                                        @Param("ownerCode") String ownerCode,
                                                        @Param("orgId") String orgId);

    Map<String, String> getDealerHeightLevelCode(@Param("appId") String appId, @Param("ownerCode") String ownerCode);


    /**
     * 通过条件查询经销商
     *
     * @param page
     * @param param
     * @return:
     * @auther: maxingjain
     * @since: 2019/10/8
     */
    List<DealerPageVO> getDealerByParam(@Param("page") Page page,
                                        @Param("param") Map<String, Object> param, @Param("cityIds") List<Long> cityIds);

    /**
     * 获取所有销售公司信息
     *
     * @auther: 李贺
     * @since: 2019/10/9
     */
    List<SaleInfoVO> querySaleInfoListByAppId(@Param("page") Page page, @Param("appId") String appId, @Param("orgTypeFactory") int orgTypeFactory);

    /**
     * 查询车厂的Id
     *
     * @auther: 李贺
     * @since: 2019/10/9
     */
    OrgDTO queryFactoryCompanyId(@Param("appId") String appId, @Param("orgTypeFactory") int orgTypeFactory);

    /**
     * 销售信息维护查询
     *
     * @auther: adu
     * @since: 2019/10/9
     */
    public List<DealerInfoDTO> selectPageSaleInfo(Page<DealerInfoDTO> page, @Param("params") Map<String, Object> queryCondition);

    public Integer addSaleInfoMaintain(DealerInfoPO dealerInfoPO);

    String findAllOrgIds(@Param("orgId") Integer orgId);

    List<DealerUserVO> getDealerUser(@Param("orgId") Integer orgId, @Param("idsArray") String[] idsArray);

    List<DealerInfoPO> getDealerByorgId(@Param("orgId") String orgId, @Param("ownerName") String ownerName);

    List<DealerInfoParentVO> getDealerInfos(@Param("orgId") Long orgId, @Param("provinceId") Long provinceId, @Param("appId") String appId);

    List<DealerOrgAreaVO> getDealerBySaleArea(@Param("orgId") String orgId, @Param("companyId") String companyId, @Param("appId") String appId, @Param("dealerCode") String dealerCode, @Param("dealerName") String dealerName);

    List<DealerInfoParentVO> getDealerByCity(@Param("provinceId") Integer provinceId, @Param("cityId") Integer cityId, @Param("countyId") Integer countyId, @Param("appId") String appId);

    DealerInfoAVO getDealerByOwner(@Param("ownerCode") String ownerCode,
                                   @Param("appId") String appId);

    DealerInfoDTO querytDealerInfo(@Param("dealerId") Long dealerId, @Param("appId") String appId);

    List<DealerOrgVO> dealerByCityOrArea(@Param("provinceId") Integer provinceId, @Param("cityId") Integer cityId, @Param("orgId") String orgId, @Param("appId") String appId);

    List<OrgParentVO> getSaleArea(@Param("dealerIds") List<Long> dealerIds);

    List<DealerPictureVO> getDealerPictures(@Param("dealerIdList") List<String> dealerIdList, @Param("dealerCodeList") List<String> dealerCodeList, @Param("appId") String appId);

    List<Long> findDealerOrgId(@Param("companyId") Long companyId);

    /**
     * 根据经销商code查询，code可以是code，也可以是name
     *
     * @param dealerInfoPO
     * @return
     */
    List<DealerOrAscOrCompanyVO> getDealerByCodeOrName(@Param("ownerCode") String ownerCode);

    List<DealerOrAscOrCompanyVO> getCompanyByCodeOrName(@Param("code") String code);

    List<DealerOrAscOrCompanyVO> getAscByCodeOrName(@Param("code") String code);
}
